<template>
  <div class="contain">
    <div v-show="flag">
      <router-view></router-view>
    </div>

    <div class="personal_center" v-show="!flag">
      <div class="personal">
        <p class="hello">你好 ,</p>
        <p class="exit" @click="exit">退出</p>
      </div>
      <div class="order" v-show="flag1">
        <p>我的订单</p>
        <ul>
          <li>订单号: 5243370454877475015</li>
          <li>收件人: {{this.payobj.name}}[{{this.payobj.tel}}]</li>
          <li>地址: {{this.payobj.province}},{{this.payobj.city}},{{this.payobj.county}},{{this.payobj.addressDetail}}</li>
          <li>总件数：{{selectnum}}</li>
          <li>总额： ￥{{price}}</li>
        </ul>
      </div>
    </div>
  </div>
</template>

<style scoped>
personal_center {
  padding: 0;
  margin: 0;
}
.personal {
  padding: 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.hello,
.exit {
  font-size: 16px;
}
.exit {
  padding: 5px 0;
  border-bottom: 1px solid black;
}
.contain {
  margin-top: 54px;
  padding: 0 20px;
  padding-top: 50px;
  box-sizing: border-box;
}
ul {
  padding: 0 10px;
}
ul li {
  font-size: 14px;
  color: #333;
  line-height: 28px;
}
</style>


<script>
import { mapState, mapGetters } from "vuex";
export default {
  data() {
    return {
      flag: false,
      flag1: false
    };
  },
  computed: {
    ...mapState("pay", { payobj: state => state.payobj }),
    ...mapGetters({
      price: "shoppingcar/price",
      selectnum: "shoppingcar/selectnum"
    })
  },
  methods: {
    exit() {
      localStorage.removeItem("username");
      this.flag = true;
      console.log("66666666");
    }
  },

  created() {
    let userinfo = localStorage.getItem("username");
    console.log(this.payobj);
    if (userinfo) {
      this.flag = false;
    } else {
      this.flag = true;
    }
    if (this.payobj.id) {
      this.flag1 = true;
    } else {
      this.flag1 = false;
    }
  }
};
</script>
